﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using hcom;
using System.Data;
using System.Text;

namespace hcms.Admin
{
	public partial class Options : System.Web.UI.Page
	{
		public string submitstate;
		private hString hstr = new hString();
		public Model model = Global.model;
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				// 初始化栏目模板下拉框
				ListItem li;// = new ListItem("", "0");
				//idtemplateid.Items.Add(li);
				DataRowCollection rows = model.getTemplateRows("t");
				int n = rows.Count;
				for (int i = 0; i < n; i++)
				{
					DataRow row = rows[i];
					li = new ListItem(row["temName"].ToString(), row["temID"].ToString());
					idtemplateid.Items.Add(li);
				}

				// 初始化文档模板下拉框
				//li = new ListItem("", "0");
				//idarttemplate.Items.Add(li);
				rows = model.getTemplateRows("a");
				n = rows.Count;
				for (int i = 0; i < n; i++)
				{
					DataRow row = rows[i];
					li = new ListItem(row["temName"].ToString(), row["temID"].ToString());
					idarttemplate.Items.Add(li);
				}

				idtemplateid.SelectedValue = model.getOption("默认栏目模板");
				idarttemplate.SelectedValue = model.getOption("默认文档模板");
				idupdatetime.Value = model.getOption("板块更新周期");
			}
			else
			{
				switch (cmd.Value)
				{
					case "save":
						save();
						break;
					default:
						throw (new Exception("不可识别的命令: \"" + cmd.Value + "\""));
				}
			}
		}

		private void save()
		{
			model.setOption("默认栏目模板", idtemplateid.SelectedValue);
			model.setOption("默认文档模板", idarttemplate.SelectedValue);
			model.setOption("板块更新周期", idupdatetime.Value);

			submitstate = "保存完毕";
		}

	}
}